import columnsData, { ColumnsItem } from './data'
import React, { useRef } from 'react';
import type { ProColumns, ActionType } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import { getTradingPasswordResetList } from './service'
import TableTitle from '@/components/TableTitle';

export default () => {
  // 表头赋值
  const columns: ProColumns<ColumnsItem>[] = columnsData
  // Table action 的引用，便于自定义触发
  const actionRef = useRef<ActionType>();

  return (
    <div>
      {/* 表格 */}
      <ProTable<ColumnsItem>
        scroll={{ x: 900 }}
        bordered
        headerTitle={<TableTitle title='交易密码重置' />}
        columns={columns}
        actionRef={actionRef}
        request={
          async params => {
            params.type = '00'
            let data = await getTradingPasswordResetList({ ...params, pageNum: params.current })
            console.log('trading', params);
            console.log('trading@@@@', data);
            const result = {
              data: data.body.list,
              total: data.body.total,
            }
            return result
          }
        }
        // 本地储存表格列的显示参数
        columnsState={{
          persistenceKey: 'TradingPasswordResetList',
          persistenceType: 'localStorage',
        }}
        // 每行表格的key
        rowKey="journalNo"
        // 搜索表单布局配置
        search={{
          labelWidth: 'auto',
        }}
        // 分页相关配置
        pagination={{
          // 初始页面数据条数
          pageSize: 10,
        }}
        dateFormatter="string"
      />
    </div>
  );
};